(function selectbogusTop5() {
    // 实例化对象
    var myChart = echarts.init(document.querySelector(".pie1 .chart"));
    // 指定配置和数据
    var option = {
        title: {
            left: 'center'
        },
        tooltip: {
            trigger: 'item'
        },
        legend: {
            orient: 'vertical',
            left: 'left'
        },
        series: [
            {

                type: 'pie',
                radius: '50%',
                data: [
                ],
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };
    $.ajax({
        url: 'http://localhost:8080/bogus/selectbogusTop5',
        type: 'get',
        dataType: 'json',
        success: function (res) {
            var name = [];
            var time = [];
            var results = []
            for (let i = 0; i < res.length; i++) {
                name[i] = res[i]["province"]
                time[i] = res[i]["counts"]

                results.push({name: name[i], value: time[i]})

            }
            console.log(results);
            // console.log(grade1);
            option.series[0].data = results;
            myChart.setOption(option);

        }
    });
    // option.xAxis[0].data = time;
    // option.series[0].data = grade;
    // // 把配置给实例对象
    // myChart.setOption(option);
    window.addEventListener("resize", function () {
        myChart.resize();
    })
}) ();




(function selectTypeTop5() {
    // 实例化对象
    var myChart = echarts.init(document.querySelector(".pie2 .chart"));
    // 指定配置和数据
    var option = {
        title: {
            left: 'center'
        },
        tooltip: {
            trigger: 'item'
        },
        legend: {
            orient: 'vertical',
            left: 'left'
        },
        series: [
            {

                type: 'pie',
                radius: '50%',
                data: [
                ],
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };
    $.ajax({
        url: 'http://localhost:8080/name/selectTypeTop5',
        type: 'get',
        dataType: 'json',
        success: function (res) {
            var name = [];
            var time = [];
            var results = []
            for (let i = 0; i < res.length; i++) {
                name[i] = res[i]["province_name"]
                time[i] = res[i]["counts"]

                results.push({name: name[i], value: time[i]})

            }
            console.log(results);
            // console.log(grade1);
            option.series[0].data = results;
            myChart.setOption(option);

        }
    });
    // option.xAxis[0].data = time;
    // option.series[0].data = grade;
    // // 把配置给实例对象
    // myChart.setOption(option);
    window.addEventListener("resize", function () {
        myChart.resize();
    })
}) ();